<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="./css/iconfont.css">
    <link rel="stylesheet" href="./css/base.css">
    <link rel="stylesheet" href="./css/couponproduct.css">
    <title>Document</title>
</head>

<body>
    <!-- 头部部分 -->
    <header>
        <div class="coupon">
            <a href="coupon.html" class="iconfont icon-fanhui"></a>
            优惠券
            <div class="imgs">
                <a href="javascript:;">
                    <img src="./images/header_app.png" alt="">
                </a>
            </div>
        </div>
    </header>

    <!-- 优惠券详情 -->

    <div class="coupon_title">--点餐前出示手机中的优惠券，即可享受优惠--</div>
    <div class="couponed">
          
        <!-- 插入模板获取数据渲染 -->

        
    </div>


    <!-- 底部部分 -->
    <footer>
        <div class="direct">
            <a href="javascript:;" class="search">登录</a>
            <a href="javascript:;" class="search">注册</a>
            <a href="#" class="backTop">
                <span></span>返回顶部</a>
        </div>
        <div class="copyright">
            <p>
                <a href="javascript:;">手机APP下载</a> 慢慢买手机版 --
                <span>掌上比价平台</span>
            </p>
            <a href="javascript:;">m.manmanbuy.com</a>
        </div>
    </footer>
</body>

</html>
<script src="./assets/art-template/template-web.js"></script>
<script src="./js/jquery.js"></script>
<script type="text/template" id="temped">
    {{each data value index}}

    <div class="coupon_content">
        <a href="javascript:;">
            <div class="coupon_img">
                {{@value.couponProductImg}}
            </div>
            <div class="particulars">
                <div class="coupon_introduce">
                    <div class="coupon_introduce">
                        <p>{{value.couponProductName}}</p>
                        <p>{{value.couponProductPrice}}</p>
                        <p>{{value.couponProductTime}}
                        </p>
                    </div>
                </div>
            </div>
        </a>
    </div>
    {{/each}}


</script>
<script>
    UrlSearch();
    console.log(id,couponTitle);
    function UrlSearch() {
        var name, value;
        var str = location.href; //取得整个地址栏
        var num = str.indexOf("?");
        var arrUrl = [];
        str = str.substr(num + 1); //取得所有参数   stringvar.substr(start [, length ]


        var arr = str.split("&"); //各个参数放到数组里
        // console.log(arr)
        for (var i = 0; i < arr.length; i++) {
            num = arr[i].indexOf("=");
            if (num > 0) {
                name = arr[i].substring(0, num);
                value = arr[i].substr(num + 1);
                this[name] = value;
            }
        }
    }

    // var myId = location.search;
    // var id = myId.substring(4);
    console.log(id);
    $.ajax({
        type: 'get',
        url: "http://193.112.55.79:9090/api/getcouponproduct",
        data: {
            couponid: id
        },
        dataType: 'json',
        success: function (res) {
            console.log(res);
            var htmlstr = template('temped', {
                data: res.result,
                name:couponTitle
            });
            // console.log(htmlstr);
            $('.couponed').html(htmlstr);

        }
    })
</script>